package maosy.oauth2.password.util

import org.apache.commons.lang3.StringUtils
import java.util.*

/**
 * 创建字符串方法
 */
fun String.Companion.makeString(length: Int, split: Char, message: String? = null): String {
    val mLength = StringUtils.length(message)
    val halfLength = (length - mLength) / 2
    val sb = StringBuilder("")
    for (i in 0..halfLength) sb.append(split)
    message?.let { sb.append(" $it ") }
    for (i in 0..halfLength) sb.append(split)
    return sb.toString()
}

/**
 * 获取uuid 方法
 */
fun String.Companion.uuid(): String = StringUtils.replace(UUID.randomUUID().toString(), "-", "")